package com.ruofeng.app.kotlin.common.bean

import com.ruofeng.app.common.bean.PersistenceBean
import org.junit.Test
import org.junit.runner.RunWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.data.mongodb.core.MongoTemplate
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner

/**
 * Created by 邱鹏 on 2017/7/28.
 */
@RunWith(SpringJUnit4ClassRunner::class)
@SpringBootTest
class PersistenceBeanTest {
    @Autowired
    lateinit var mongoTemplate: MongoTemplate;
    @Autowired
    lateinit var persistence: PersistenceBean;
    @Test
    fun callScriptDirect() {
        var result=persistence.callScriptDirect("function(x){db.getCollection('echo').save({test:x});   return 5;}", mapOf("hello" to "think", "world" to "manager"));
        println(result)
    }

    @Test
    fun callNamedScript() {
        var result=persistence.callNamedScript("deleteMenu", mapOf(  "code" to "node-2-1", "world" to "manager"))
        println(result)
    }

    @Test
    fun registerScript() {
    }

}